﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WebService.Entity;
using WebService.Model;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WebService.IServices;

namespace WebService.Controllers
{
    /// <summary>
    /// 测试接口
    /// </summary>
    [Route("api/Test")]
    [ApiController]
    [Authorize]
    public class TestController : ControllerBase
    {
        readonly IAdvertisementServices advertisementServices;

        public TestController(IAdvertisementServices advertisementServices)
        {
            this.advertisementServices = advertisementServices;
        }

        [HttpPost, Route("MyTest")]
        public List<TestEntity> MyTest([FromBody] int? count)
        {
            List<TestEntity> d = new List<TestEntity>();
            for (int i = 0; i < count; i++)
            {
                d.Add(new TestEntity()
                {
                    Name = i.ToString(),
                    Age = i + 1,
                    Sleep = (i + 10).ToString()
                });
            }
            return d;
        }




        /// <summary>
        /// 获取求得的和值
        /// </summary>
        /// <param name="i">传入i</param>
        /// <param name="j">传入j</param>
        /// <returns>计算的值</returns>
        [HttpGet, Route("Get")]
        public async Task<List<Advertisement>> Get(int id)
        {
            return await advertisementServices.Query(d => d.Id == id);
        }
    }

    public class TT
    {
        public int Count { get; set; }
    }
}